﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using Model;
namespace DAL
{
    public class Consult_向老师咨询_DAL
    {
        /// <summary>
        /// 向轮播老师咨询
        /// </summary>
        /// <returns></returns>
        public List<Consult_向老师咨询_> ShowConsult()
        {
            using (SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=JingRui;Integrated Security=True"))
            {
                
                string sql = "select * from [Consult(向老师咨询)] where Consultid>=5";
                SqlCommand com = new SqlCommand(sql, con);
                SqlDataAdapter sd = new SqlDataAdapter(com);
                DataTable dt = new DataTable();
                sd.Fill(dt);
                List<Consult_向老师咨询_> list = new List<Consult_向老师咨询_>();
                foreach (DataRow item in dt.Rows)
                {
                    Consult_向老师咨询_ a = new Consult_向老师咨询_();
                    a.Consultid = Convert.ToInt32(item["Consultid"]);
                    a.Consultname = item["Consultname"].ToString();
                    a.Consultjop = item["Consultjop"].ToString();
                    a.Consultjianjie = item["Consultjianjie"].ToString();
                    a.Consultimg = item["Consultimg"].ToString();
                    a.Consultschool = item["Consultschool"].ToString();
                    a.Consultchengjiu = item["Consultchengjiu"].ToString();
                    list.Add(a);
                }
                return list;

            }
        }



        /// <summary>
        /// 向静止老师咨询
        /// </summary>
        /// <returns></returns>
        public List<Consult_向老师咨询_> ShowTeacher()
        {
            using (SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=JingRui;Integrated Security=True"))
            {
                
                string sql = "select * from [Consult(向老师咨询)] where Consultid<5";
                SqlCommand com = new SqlCommand(sql, con);
                SqlDataAdapter sd = new SqlDataAdapter(com);
                DataTable dt = new DataTable();
                sd.Fill(dt);
                List<Consult_向老师咨询_> list = new List<Consult_向老师咨询_>();
                foreach (DataRow item in dt.Rows)
                {
                    Consult_向老师咨询_ a = new Consult_向老师咨询_();
                    a.Consultid = Convert.ToInt32(item["Consultid"]);
                    a.Consultname = item["Consultname"].ToString();
                    a.Consultjop = item["Consultjop"].ToString();
                    a.Consultjianjie = item["Consultjianjie"].ToString();
                    a.Consultimg = item["Consultimg"].ToString();
                    a.Consultschool = item["Consultschool"].ToString();
                    a.Consultchengjiu = item["Consultchengjiu"].ToString();
                    list.Add(a);
                }
                return list;

            }
        }
    }
}
